<?php


include '../test_upload_pic.php';
session_start();
ob_start();
date_default_timezone_set('PRC');
//var_dump($_POST);exit;
$error='';
$srcId = $_GET['id'];
$src = '';
$srcTitle = '';



//将内容插入到数据库中
if(empty($error)){
	include '../config.php';
	$link=mysql_connect(HOST,DBUSER,DBPASS) or die('数据库连接失败');
	mysql_select_db(DBNAME,$link);
	mysql_set_charset('utf8');


	$sql= "SELECT * FROM t_flash WHERE srcId='".$srcId."'";
	$result=mysql_query($sql);
	if(mysql_num_rows($result)>0){
		$error='您要输入的行程已存在flash！请做修改';
	}
	mysql_free_result($result);
	
	$sql = "SELECT * FROM t_plan  WHERE  id=".$srcId;
	$result = mysql_query($sql);
	if(!empty($result)&&mysql_num_rows($result)>0){
		while($rows = mysql_fetch_assoc($result)){
			$srcTitle=$rows['title'];
			$src=$rows['head_pic'];
		}
	}
	if(empty($error)){
		$sql= "INSERT INTO t_flash (srcId,srcTitle,src)	VALUES('".$srcId."','".$srcTitle."','".$src."')";
		echo $sql;
		$result=mysql_query($sql);
		$tid=mysql_insert_id();
		if($tid<=0){
			$error=$sql.$tid.'插入数据库失败!';
		}
	}
	mysql_close($link);
}
//错误跳转
if(empty($error)){
	header('Location:flashControlList.php');
}else{
	header('Location:../system/planList.php?error='.$error);
}
ob_end_flush();
?>